package com.clannad.eduservice.controller;


import com.clannad.commonutils.R;
import com.clannad.eduservice.entity.subject.OneSubject;
import com.clannad.eduservice.service.EduSubjectService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * <p>
 * 课程科目 前端控制器
 * </p>
 *
 * @author clannad
 * @since 2022-08-10
 */
@RestController
@RequestMapping("/eduservice/subject")
//@CrossOrigin
@Api(tags = "课程分类")
public class EduSubjectController {
    @Autowired
    private EduSubjectService eduSubjectService;

    @PostMapping("addSubject")
    @ApiOperation("课程分类文件上传")
    public R addSubject(MultipartFile file){
        //上传的文件
        eduSubjectService.saveSubject(file,eduSubjectService);
        return R.ok();
    }

    @GetMapping("/getAllSubject")
    @ApiOperation("查询所有分类列表")
    public R getAllSubject(){
        List<OneSubject> list=eduSubjectService.getAllOneTwoSubject();
        return R.ok().data("list",list);
    }
}

